package cn.jn.lhm.netty.part02;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.NettyRuntime;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author lhm 2753914576@qq.com
 * @time 2023/4/20 - 21:38
 **/
@Slf4j
public class TestEventLoop {
    public static void main(String[] args) {
        System.out.println("NettyRuntime.availableProcessors() = " + NettyRuntime.availableProcessors());

        EventLoopGroup loopGroup = new NioEventLoopGroup(2);
        System.out.println(loopGroup.next());
        System.out.println(loopGroup.next());
        System.out.println(loopGroup.next());

        loopGroup.next().submit(() -> {
            log.info("ok");
        });

        loopGroup.next().scheduleAtFixedRate(() -> {
            log.info("hello");
        }, 1L, 1L, TimeUnit.SECONDS);
        // System.out.println(NettyRuntime.availableProcessors() + "----" + Runtime.getRuntime().availableProcessors());
    }
}
